<template>
    <div class="box-column container-grid">
        <div class="box-row box-center-start info-el" style="display:flex;justify-content: space-between;">
            <div>梯控名称：{{ infoData.door_name }}&emsp;&emsp;&emsp;梯控guid：{{ infoData.door_guid}}</div>
            <div>
                <el-button icon="el-icon-back" class="btn-blue" @click="go('equipmentLadderTable')" >
                    返回
                </el-button>
            </div>
        </div>
        <ux-header-search
            ref="searchHeader"
            v-bind="enquiryData"
            :btnsData="{ permissionsData }"
            @search="onQueryClick"
        ></ux-header-search>
        <div class="box-flex1 table">
            <vxe-grid
                v-bind="tableConfig"
                :data="dataStore.data"
                :columns="table.columns"
            >
                <template v-slot:operate="{ row }">
                    <ux-btn-group
                        :btns="table.btns"
                        :data="{ row, permissionsData }"
                    ></ux-btn-group>
                </template>
            </vxe-grid>
        </div>
        <div class="pagination-el box-row box-center-end">
            <el-pagination
                @size-change="onSizeChange"
                @current-change="onCurrentChange"
                :current-page="dataStore.proxy.page"
                :page-size="dataStore.proxy.pageSize"
                :page-sizes="dataStore.pageSizes"
                :total="dataStore.pagination.total"
                :layout="'total, sizes, prev, pager, next, jumper'"
            ></el-pagination>
        </div>
        <dialogForm
            ref="dialogForm"
            @submitSuccess="onSubmitSuccess"
            @closeDialog="onCloseDialog"
        ></dialogForm>
        <statusForm
        ref="statusForm"
        @submitSuccess="onSubmitSuccess"
        @closeDialog="onCloseDialog"
    ></statusForm>
    </div>
</template>

<script  lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { Action } from 'vuex-class';
import { mixinTableStore } from '@/mixin/table/Store';
import { mixinTableHeader } from '@/mixin/table/Header';
import { mixinTableOperation } from '@/mixin/table/Operation';
import { mixinDialogFormParent } from '@/mixin/dialog/FormParent';
import { mixinTabPage } from '@/mixin/tab/Page';
import { mixinAccess } from '@/mixin/Access';
import dialogForm from './ConfEdit.vue';
import statusForm from './PortStatus.vue';
@Component({
    name: 'ladderConfTable',
    mixins: [
        mixinTableStore,
        mixinTableHeader,
        mixinTableOperation,
        mixinDialogFormParent,
        mixinTabPage,
        mixinAccess
    ],
    components: {
        dialogForm, statusForm
    }
})
export default class ladderConfTable extends Vue {
    @Action('equipmentLadder/portList') getList: any;
    infoData: any = {};
    editInit({ data }) {
        const me = this as any;
        me.infoData = data;
        me.lodaByDefaultParams({ door_sn: data.door_sn });
    }
    dataStore: any = {
        proxy: {
            autoLoad: false
        }
    };

    table: any = {
        btns: [
            {
                label: '设置',
                condition: [
                    'permissionsData.conf'
                ],
                handleClick: (this as any).onEditClick
            }
        ],
        // 列配置
        columns: [
            {
                fixed: 'left',
                width: 70,
                type: 'seq',
                title: '序号'
            },
            {
                fixed: 'left',

                title: '梯控端口',
                field: 'port_num'
            },
            {

                title: '开闭状态',
                field: 'port_status',
                formatter: function ({ cellValue }) {
                    return ['', '开启', '关闭'][cellValue];
                },
                className: function ({ row }) {
                    return ['', 'green ', 'red'][row.port_status];
                }
            },
            {

                title: '梯控楼层',
                field: 'port_floor'
            },
            {

                title: '楼层名称',
                field: 'remark'
            },
            {
                showOverflow: 'ellipsis',
                fixed: 'right',
                slots: { default: 'operate' },
                title: '操作',
                width: 160
            }
        ]
    };

    editstatus() {
        (this as any).onEditClick({ row: this.infoData }, 'statusForm')
    }
    // 查询头配置
    enquiryData: any = {
        searchBtn: {
            condition: ['permissionsData.query']
        },
        fields: [
            {
                field: 'port_num',
                label: '梯控端口'
            }
        ],
        btns: [
            {
                label: '开闭状态',
                data: { door_name: '11111' },
                class: 'btn-blue',
                icon: 'el-icon-turn-off',
                param: "statusForm",
                condition: ['permissionsData.status'],
                handleClick: (this as any).editstatus
            }
        ]
    };
}
</script>
